import log4js from 'log4js'

log4js.configure({
  appenders: { cheese: { type: 'console', filename: 'cheese.log' } },
  categories: { default: { appenders: ['cheese'], level: 'debug' } },
})

/**
 * 获取日志记录工具实例
 * @example
 * const logger = loggerFactory('user')
 * logger.debug('你好') // 输出: [2010-01-17 11:43:37.987] [DEBUG] user - 你好
 * logger.info('你好') // 输出: [2010-01-17 11:43:37.987] [INFO] user - 你好
 * logger.warn('你好') // 输出: [2010-01-17 11:43:37.987] [WARN] user - 你好
 * logger.error('你好') // 输出: [2010-01-17 11:43:37.987] [ERROR] user - 你好
 * logger.fatal('你好') // 输出: [2010-01-17 11:43:37.987] [FATAL] user - 你好
 * @param category 日志分类标识
 */
export function loggerFactory(category: string) {
  return log4js.getLogger(category)
}
